import { Component } from 'react';
class shijian extends Component {
  constructor() {
    super();
    this.state={
      obj:10
    }
  }

  add = () => {
    this.setState({
      obj:this.state.obj+1
    })
  }

  // 传参
  can = (e) => {
    console.log(e.target.dataset.id);
  }


  render() { 
    return ( 
      <>
        <div className=''>
            obj{this.state.obj}
            <button onClick={this.add}>箭头函数点击+1</button>
            <button onClick={this.add.bind(this)}>bind点击+1</button>

          {/* 点击跳转详情传参 */}
          <button data-id='100' onMouseLeave={(e)=>this.can(e)}>跳转传参</button>

        </div>
      </>
     );
  }
}
 
export default shijian;